package com.ssrs.devTest;


import com.ssrs.dev.mapper.DeviceMapper;
import com.ssrs.dev.service.IClassroomService;
import com.ssrs.dev.service.IDeviceService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Info：MyBatis Plus 各项增删改查功能测试
 *
 * @author: Chen Xiuhao
 * @date: 2021-05-20 0020 15:30
 */

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring.xml")
public class testMP {

    @Autowired
    private DeviceMapper deviceMapper;

    @Autowired
    private IDeviceService deviceService;

    @Autowired
    private IClassroomService classroomService;

    @Test
    public void TestMP() {

//        List<DeviceVO> devices = test1("东");
//        if (devices != null) {
//            for (DeviceVO device : devices) {
//                System.out.println(device.toString());
//            }
//        } else
//            System.out.println("空");
    }

    /**
     * 场景：
     * <p>
     * A 表为教室表，有ID、楼栋、门牌号等属性
     * B表为设备表，，有ID、设备名、教室ID等属性
     * <p>
     * 每个设备只能放入一个教室，每个教室可以有多个设备。
     * <p>
     * 要求：查询指定楼栋里的所有设备（根据楼栋查询设备）
     *
     * @param building 楼栋名
     */
//    private List<DeviceVO> test1(String building) {
//        EntityWrapper<Device> wrapper = new EntityWrapper<>();
//        wrapper.setSqlSelect()

//        List<Device> devices = deviceService.selectList(
//                new EntityWrapper<Device>().in("id", classroomService.selectList(
//                        new EntityWrapper<Classroom>().setSqlSelect("id").like("room_building", building)
//                        )
//                )
//        );
//        List<Classroom> classrooms = classroomService.selectList(
//                new EntityWrapper<Classroom>().like("room_building", building)
//        );
//        List<Integer> resultList = new ArrayList<>();
//        classrooms.forEach(item -> {
//            resultList.add(item.getId());
//        });
//
//        List<Device> devices = deviceService.selectList(
//                new EntityWrapper<Device>().in("device_classroom", resultList)
//        );
//
//        return devices;
        //        deviceVOS.forEach(System.out::println);

//        return deviceMapper.getDeviceVOList();


//    }


}
